﻿//控制android app设置图标
function showSet() {
    document.getElementById("settings").removeAttribute("class");
}

//angular开始
var app = angular.module('myApp', ['angular.filter']);
app.factory('RightService', RightService);

app.controller('myCtrl', function ($scope, $http, $filter, RightService) {

    $scope.metaclass = {};//用于保存元模型的定义
    //判断用户登录状态
    $http({
        url: '../auth/userinfo',
        method: "GET",
        headers: {
            'Cache-Control': 'no-store',
            'Pragma': 'no-cache'
        }
    }).success(function (response) {

        if (response.user == null) {
            var defaultuser = getQueryString('defaultuser');
            if (defaultuser) {
                //url中带入了默认用户信息，直接以默认用户登陆
                $http({
                    url: '../app/login',
                    method: "POST",
                    data: {
                        'userName': 'JRIDGE',
                        'password': '123456'
                    },
                    headers: {
                        'Cache-Control': 'no-store',
                        'Pragma': 'no-cache'
                    }
                }).success(function (response) {
                    //登陆成功,去获取当前用户
                    $http({
                        url: 'auth/userinfo',
                        method: "GET",
                        headers: {
                            'Cache-Control': 'no-store',
                            'Pragma': 'no-cache'
                        }
                    }).success(function (response) {
                        if (response.user != null) {
                            $scope.initdata(response);
                        }
                        else {
                            window.location.href = 'login.html'
                        }
                    });
                });
            }
            else {
                window.location.href = 'login.html'
            }
        } else {
            $scope.initdata(response);
        }
    })

    /*获取完用户信息后，设置到当前页面*/
    $scope.initdata = function (response) {
        $scope.userinfo = response;

        $scope.getMeta();
        $scope.getLabelList();

        //初始化完成后，如果参数中含有search，调用search方法
        var searchtext = getQueryString('searchtext');
        if (searchtext) {
            $scope.keyword = searchtext;
            $scope.search();
        }
        else {
            $scope.getRootList();
        }

        if (window.jcloudandroid) {
            window.jcloudandroid.settoken(response.tk);
        }
    }

    //获取 Meta
    $scope.meta = {};
    $scope.getMeta = function () {
        $http({
            url: '../design/metapdmjson',
            method: "GET",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            $scope.meta = response;
            //取SysDocumentRev的属性
            var url1 = '../design/loadClassJson?name=' + $scope.meta.metaclass.SysDocumentRev;
            $http({
                url: url1,
                method: "POST",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.metaclass[$scope.meta.metaclass.SysDocumentRev] = response;
            });
            var url2 = '../design/loadClassJson?name=' + $scope.meta.metaclass.SysFolder;
            //取folder的属性
            $http({
                url: url2,
                method: "POST",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.metaclass[$scope.meta.metaclass.SysFolder] = response;
            });
        });
    }


    ////////PDM专用，解决下载和打开url问题////////
    $scope.formatDataForPDM = function (data) {
        for (var i = 0; i < data.length; i++) {
            if (data[i].type == "PDMDOCUMENTREV") {
                data[i].properties.downurl = "../file/DownFileByDocRev?_strDocRevID=" + data[i].id + "&_strDocRevClassType=" + data[i].type;
                data[i].properties.linkurl = "../file/DownFileByDocRev?_strDocRevID=" + data[i].id + "&_strDocRevClassType=" + data[i].type;
            }
        }
        return data;
    }

    //搜索
    $scope.keyword = "";
    $scope.search = function () {
        $scope.includePath = "loading.html";  //显示loading
        $http({
            url: '../folderlist/dosearch?withfolder=true&q=' + $scope.keyword,
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            $scope.data = $scope.formatDataForPDM(response);
            $scope.includePath = "list-view.html";  //显示视图
            $scope.folder_name = true;
            preparelist();
            //显示“搜索结果”
            $scope.temp = {
                "id": -1,
                "properties": {
                    "type": "",
                    "name": "搜索结果",
                    "description": "",
                    "creator": "",
                    "creationdate": ""
                },
                "type": "MesFolder"
            };
            $scope.curFolderNames.splice(1, $scope.curFolderNames.length - 1);
            $scope.curFolderNames.push($scope.temp);

        });
    }

    //按回车键搜索
    $scope.keydownSearch = function () {
        if (event.keyCode == 13) {
            $scope.search();
        }
    }

    //获取根目录列表
    $scope.includePath = "";
    $scope.getRootList = function () {
        $scope.includePath = "loading.html";  //显示loading
        $http({
            url: '../folderlist/sublistpdm',
            method: "GET",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            $scope.data = $scope.formatDataForPDM(response);
            $scope.includePath = "grid-view.html";  //显示视图
            preparelist(); //把data.j_tags格式化成对象

        });
    }

    //获取自定义分类标签列表    
    $scope.labelListStyle = {
        "text-align": "center"
    };
    $scope.getLabelList = function () {
        $scope.labels = new Array();
        $http({
            url: '../UserProfile/labels',
            method: "GET",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response[0] == null) {
                //如果标签列表是空的，新建一个“收藏夹”
                $http({
                    url: '../UserProfile/addlabel?label=' + "收藏夹",
                    method: "POST",
                    headers: {
                        'Cache-Control': 'no-store',
                        'Pragma': 'no-cache'
                    }
                }).success(function (response) {
                    if (response.resFlag != 0) {
                        alert(response.errMsg);
                    }
                });
            } else {
                $scope.labels = response;

            }
        });

    }


    //新增自定义标签

    $scope.labelName = "";
    $scope.addLabel = function () {
        $http({
            url: '../UserProfile/addlabel?label=' + $scope.labelName,
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag == 0) {
                $scope.labelName = "";
                $http({
                    url: '../UserProfile/labels',
                    method: "GET",
                    headers: {
                        'Cache-Control': 'no-store',
                        'Pragma': 'no-cache'
                    }
                }).success(function (response) {
                    $scope.labels = response;
                });
            } else {
                alert(response.errMsg);
            }

        });
    }

    //删除自定义标签
    $scope.removeLabel = function (index) {
        $http({
            url: '../UserProfile/removelabel?label=' + encodeURI($scope.labels[index]),
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag == 0) {
                $http({
                    url: '../UserProfile/labels',
                    method: "GET",
                    headers: {
                        'Cache-Control': 'no-store',
                        'Pragma': 'no-cache'
                    }
                }).success(function (response) {
                    $scope.labels = response;

                });
            } else {
                alert(response.errMsg);
            }

        });
    }

    //只有被添加过标签的才会有j_tags；
    //此函数把j_tags格式化成一个数组tags,把tags加到data的每一个元素；
    //如果没有j_tags，给data的每一个元素添加空数组tags
    preparelist = function () {
        for (var i = 0; i < $scope.data.length; i++) {
            if ($scope.data[i].properties.j_tags != null) {
                var tags = eval("(" + $scope.data[i].properties.j_tags + ")");

                $scope.data[i].tags = tags;
            }
            else {
                $scope.data[i].tags = [];
            }
        }
    }

    //点击标签按钮时
    $scope.tempList = "";
    $scope.clickLabelBtn = function (list) {
        $scope.tempList = list;
        $scope.tempLabels = new Array();
        $scope.tempLabels = $scope.labels.slice(0);//数组的复制
        for (var i = 0; i < $scope.tempList.tags.length; i++) {
            for (var j = 0; j < $scope.tempLabels.length; j++) {
                if ($scope.tempList.tags[i] == $scope.tempLabels[j]) {
                    $scope.tempLabels.splice(j, 1);
                }
            }
        }
    }

    //添加到收藏夹   
    $scope.addFavorite = function (index) {
        var url = '../UserProfile/addfavorite?id=' + $scope.tempList.id + '&objtype=' + $scope.tempList.type + '&label=' + encodeURI($scope.tempLabels[index]);
        $http({
            url: url,
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag == 0) {
                $scope.refreshCur();
            } else {
                alert(response.errMsg);
            }
        });

    }

    //从分类标签中移除(取消收藏)
    $scope.removeFavorite = function (index) {
        var url = '../UserProfile/removefavorite?id=' + $scope.tempList.id + '&objtype=' + $scope.tempList.type + '&label=' + encodeURI($scope.tempList.tags[index]);
        $http({
            url: url,
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag == 0) {
                $scope.refreshCur();
            } else {
                alert(response.errMsg);
            }
        });
    }

    //获取分类标签里的内容列表
    $scope.favoriteList = function (index) {
        $scope.includePath = "loading.html";  //显示loading
        $http({
            url: '../UserProfile/favoritelist?label=' + encodeURI($scope.labels[index]),
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            $scope.data = $scope.formatDataForPDM(response);
            $scope.includePath = "grid-view.html";  //显示视图
            preparelist();
            $scope.temp = {
                "id": -1,
                "properties": {
                    "type": "",
                    "name": $scope.labels[index],
                    "description": "",
                    "creator": "",
                    "creationdate": ""
                },
                "type": $scope.meta.metaclass.SysFolder
            };
            $scope.curFolderNames.splice(1, $scope.curFolderNames.length - 1);
            $scope.curFolderNames.push($scope.temp);

        });
    }




    //用于筛选的变量
    $scope.fileName;
    $scope.fileSize;
    $scope.srcVer;
    $scope.version;
    $scope.creator;
    $scope.createdDate;

    //排序
    $scope.orderflag = false;
    $scope.label4name = "▼";
    $scope.nameIsActive = true;
    $scope.creatorIsActive = false;
    $scope.creationdateIsActive = false;
    $scope.byname = function () {
        $scope.orderby = 'properties.name';
        $scope.orderflag = !$scope.orderflag;
        if ($scope.orderflag == false) {
            $scope.label4name = "▼";
        } else {
            $scope.label4name = "▲";
        }
        $scope.label4creator = "";
        $scope.label4creationdate = "";
        $scope.nameIsActive = true;
        $scope.creatorIsActive = false;
        $scope.creationdateIsActive = false;
    }
    $scope.bycreator = function () {
        $scope.orderby = 'properties.creator';
        $scope.orderflag = !$scope.orderflag;
        if ($scope.orderflag == false) {
            $scope.label4creator = "▼";
        } else {
            $scope.label4creator = "▲";
        }
        $scope.label4name = "";
        $scope.label4creationdate = "";
        $scope.nameIsActive = false;
        $scope.creatorIsActive = true;
        $scope.creationdateIsActive = false;
    }
    $scope.bycreationdate = function () {
        $scope.orderby = 'properties.creationdate';
        $scope.orderflag = !$scope.orderflag;
        if ($scope.orderflag == false) {
            $scope.label4creationdate = "▼";
        } else {
            $scope.label4creationdate = "▲";
        }
        $scope.label4creator = "";
        $scope.label4name = "";
        $scope.nameIsActive = false;
        $scope.creatorIsActive = false;
        $scope.creationdateIsActive = true;
    }

    //点击保存
    $scope.onClickSave = function () {
        RightService.CheckRight($scope.userinfo.user, $scope.obj, $scope.parentObj, 'Base', 'Modify', 'Pdm', 'Pdm', 'FolderMgr').success(function (response) {
            if (response.resFlag == 0) {
                if (response.result === 1) {
                    $scope.operateGraphNodeWithoutAudit($scope.obj, 130);
                }
                if (response.result === 0) {
                    alert(response.description)
                }
            } else {
                alert(response.errMsg)
            }
        });
    }

    //点击删除时
    $scope.onClickDelete = function () {
        RightService.CheckRight($scope.userinfo.user, $scope.obj, $scope.parentObj, 'Base', 'Remove', 'Pdm').success(function (response) {
            if (response.resFlag == 0) {
                if (response.result === 1) {
                    $scope.operateGraphNodeWithoutAudit($scope.obj, 1152);
                }
                if (response.result === 0) {
                    alert(response.description)
                }
            } else {
                alert(response.errMsg)
            }
        });
    }


    //详情  
    $scope.openDetails = function (list) {
        $scope.obj = list;
        if ($scope.curFolderNames[$scope.curFolderNames.length - 1].id !== -1) {
            $scope.parentObj = $scope.curFolderNames[$scope.curFolderNames.length - 1];
        }
    };

    /*操作graph节点*/
    $scope.operateGraphNodeWithoutAudit = function (obj, strategy) {
        var graph = {
            "roots": [
                {
                    "entity": obj,
                    "nodeId": 0,
                    "children": [],
                    "strategy": strategy
                }
            ]
        };

        $http({
            url: getRootPath() + '/jridgeadvanced/batchdo',
            method: 'POST',
            data: graph,
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag == 0) {
                if ($scope.parentObj.id === 0) {
                    $scope.getRootList();
                    $('#edit').modal('hide');
                }
                if ($scope.parentObj.id !== 0) {
                    $scope.subfolder($scope.parentObj);
                    $('#edit').modal('hide');
                }
            } else {
                alert(response.errMsg);
            }
        });
    }

    //在上传之前
    $scope.beforeUpload = function () {
        existingObj = $scope.curFolderNames[$scope.curFolderNames.length - 1];
        $scope.parentObj = $scope.curFolderNames[$scope.curFolderNames.length - 1];
        $scope.obj = {
            "id": 0,
            "type": "PdmDocumentRev",
            "properties": {}
        }
        RightService.CheckRight($scope.userinfo.user, $scope.obj, $scope.parentObj, 'Base', 'Create', 'Pdm', 'Pdm', 'FolderMgr').success(function (response) {
            if (response.resFlag == 0) {
                if (response.result === 1) {
                    $('#upload').modal('show');
                }
                if (response.result === 0) {
                    alert(response.description)
                }
            } else {
                alert(response.errMsg)
            }
        });
    }

    //在新建文件夹之前
    $scope.beforeNewFolder = function () {
        if ($scope.curFolderNames[$scope.curFolderNames.length - 1].id !== -1) {
            $scope.parentObj = $scope.curFolderNames[$scope.curFolderNames.length - 1];
        }
        $scope.obj = {
            "id": 0,
            "type": "PdmFolder",
            "properties": {}
        }
        RightService.CheckRight($scope.userinfo.user, $scope.obj, $scope.parentObj, 'Base', 'Create', 'Pdm', 'Pdm', 'FolderMgr').success(function (response) {
            if (response.resFlag == 0) {
                if (response.result === 1) {
                    $('#newFolder').modal('show');
                }
                if (response.result === 0) {
                    alert(response.description)
                }
            } else {
                alert(response.errMsg)
            }
        });
    }

    //batchdoRelation
    $scope.batchdoRelation = function (obj, childrenObj, relationName, childrenStrategy) {
        var graph = {
            "roots": [
                {
                    "entity": obj,
                    "nodeId": 0,
                    "children": [],
                    "strategy": 136
                }
            ]
        };
        if (childrenStrategy === 24 || childrenStrategy === 17) {
            for (var i = 0; i < childrenObj.length; i++) {
                graph.roots[0].children.push(
                    {
                        "entity": childrenObj[i],
                        "relation": {
                            "properties": {},
                            "lId": 0,
                            "lType": relationName,
                            "objIdA": childrenObj[i].id,
                            "aClassType": null,
                            "objIdB": 0,
                            "bClassType": null
                        },
                        "nodeId": 1,
                        "children": [],
                        "strategy": childrenStrategy
                    }
                );
            }
        }

        if (childrenStrategy === 72) {
            for (var i = 0; i < childrenObj.length; i++) {
                childrenObj[i].strategy = childrenStrategy;
            }
            graph.roots[0].children = childrenObj;
        }

        $http({
            url: getRootPath() + '/jridgeadvanced/batchdo',
            method: 'POST',
            data: graph,
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag == 0) {
                if (obj.id === 0) {
                    $scope.getRootList();
                    $('#newFolder').modal('hide');
                }
                if (obj.id !== 0) {
                    $scope.subfolder(obj);
                    $('#newFolder').modal('hide');
                }

            } else {
                alert(response.errMsg);
                return;
            }
        })
    }

    //进入文件夹
    $scope.folderId = "";
    $scope.curFolderNames = [{
        "id": 0,
        "properties": {
            "type": "",
            "name": "根目录",
            "description": "",
            "creator": "",
            "creationdate": ""
        },
        "type": "PdmFolder"
    }]
    //初始化上传文件夹
    $scope.existingObj = "";

    $scope.subfolder = function (list) {
        if (list.type == $scope.meta.metaclass.SysFolder) {
            $scope.includePath = "loading.html";  //显示loading
            if (list.id !== $scope.curFolderNames[$scope.curFolderNames.length - 1].id) {
                $scope.curFolderNames.push(list);
            }
            //手机端的上传目录
            $scope.existingMobileObj = $scope.curFolderNames[$scope.curFolderNames.length - 1];
            $scope.parentMobileObj = $scope.curFolderNames[$scope.curFolderNames.length - 1];
            //判断是否为根目录，若不是根目录，则允许相机进行拍照，进行文件上传
            if ($scope.curFolderNames.length !== 1) {
                $scope.enableCamera = true;
            }

            $http({
                url: '../folderlist/sublistpdm?folderid=' + encodeURI(list.id) + "&bpdm=true",
                method: "GET",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.data = $scope.formatDataForPDM(response);
                $scope.includePath = "grid-view.html";  //显示视图               
                preparelist();

            });
        }
    };
    $scope.gotoFolder = function (folderid) {
        if (!folderid)
            return;
        $scope.includePath = "loading.html";  //显示loading

        $http({
            url: 'folderlist/sublistpdm?folderid=' + folderid,
            method: "GET",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            $scope.data = $scope.formatDataForPDM(response);
            $scope.includePath = "grid-view.html";  //显示视图               
            preparelist();

        });
    }

    loadfavlist = function (index) {
        $scope.includePath = "loading.html";  //显示loading
        $http({
            url: 'UserProfile/favoritelist?label=' + $scope.labels[$scope.labelNumber],
            method: "POST",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            $scope.data = $scope.formatDataForPDM(response);
            $scope.includePath = "grid-view.html";  //显示视图
            preparelist();
            $scope.curFolderNames.splice(index + 1, $scope.curFolderNames.length - index);
        });


    }

    //返回上一级菜单
    $scope.goBack = function (index) {
        $scope.includePath = "loading.html";  //显示loading
        for ($scope.loop = 0; $scope.loop < $scope.labels.length; $scope.loop++) {
            if ($scope.curFolderNames[index].properties.name == $scope.labels[$scope.loop]) {
                $scope.isLabel = true;
                $scope.labelNumber = $scope.loop;

            }
        }
        if ($scope.curFolderNames[index].id === 0) {
            $http({
                url: '../folderlist/sublistpdm',
                method: "GET",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.data = $scope.formatDataForPDM(response);
                $scope.includePath = "grid-view.html";  //显示视图
                preparelist();

                $scope.curFolderNames.splice(index + 1, $scope.curFolderNames.length - index);

            });
        } else if ($scope.isLabel == true) {

            loadfavlist(index);

        } else {
            $http({
                url: '../folderlist/sublistpdm?folderid=' + $scope.curFolderNames[index].id,
                method: "GET",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.data = $scope.formatDataForPDM(response);
                $scope.includePath = "grid-view.html";  //显示视图
                preparelist();
                $scope.curFolderNames.splice(index + 1, $scope.curFolderNames.length - index);
            });
        }

    }

    //刷新当前的目录
    $scope.refreshCur = function () {
        $scope.includePath = "loading.html";  //显示loading
        for ($scope.loop = 0; $scope.loop < $scope.labels.length; $scope.loop++) {
            if ($scope.curFolderNames[$scope.curFolderNames.length - 1].properties.name == $scope.labels[$scope.loop]) {
                $scope.isLabel = true;
                $scope.labelNumber = $scope.loop;

            }
        }
        if ($scope.curFolderNames[$scope.curFolderNames.length - 1].id == "root") {
            $http({
                url: '../folderlist/sublistpdm',
                method: "GET",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.data = $scope.formatDataForPDM(response);
                $scope.includePath = "grid-view.html";  //显示视图
                preparelist();


            });
        } else if ($scope.isLabel == true) {

            $http({
                url: '../UserProfile/favoritelist?label=' + $scope.labels[$scope.labelNumber],
                method: "POST",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.data = $scope.formatDataForPDM(response);
                $scope.includePath = "grid-view.html";  //显示视图
                preparelist();

            });

        } else if ($scope.curFolderNames[$scope.curFolderNames.length - 1].properties.name == "搜索结果") {
            $scope.search();
        }
        else {
            $http({
                url: '../folderlist/sublistpdm?folderid=' + $scope.curFolderNames[$scope.curFolderNames.length - 1].id,
                method: "GET",
                headers: {
                    'Cache-Control': 'no-store',
                    'Pragma': 'no-cache'
                }
            }).success(function (response) {
                $scope.data = $scope.formatDataForPDM(response);
                $scope.includePath = "grid-view.html";  //显示视图
                preparelist();

            });
        }

    }

    //下载文件夹
    $scope.downfolder = function (folderid) {
        var url = ".././folderlist/FindFolderZipFile?renew=true&folderid=" + folderid;
        $http({
            url: url,
            method: "GET",
            headers: {
                'Cache-Control': 'no-store',
                'Pragma': 'no-cache'
            }
        }).success(function (response) {
            if (response.resFlag != 0) {
                alert(response.errMsg);
            }
            else {
                var url = getRootPath() + "/" + response.url;
                window.open(url);
            }

        });
    }

    //打开PDF
    $scope.openPDF = function (list) {
        window.open("./pdfviewer/web/viewer.html?docid=" + list.id)
    }

    //打开图片
    //在线浏览图片
    $scope.openImg = function () {
        $('.image').viewer();
    }


    //tooltip
    $scope.tooltip = function () {
        $(function () { $("[data-toggle='tooltip']").tooltip(); });
    }

    //拍照上传
    $scope.phoneLoadJPG = function () {
        window.location.href = "phoneLoadJPG.html"
    }


    $scope.bytesToSize = function (bytes) {
        var src = parseFloat(bytes);
        if (src === 0) return '0 B';
        if (src) {
            var sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
            var i = Math.floor(Math.log(src) / Math.log(1024));
            return (src / Math.pow(1024, i)).toPrecision(3) + ' ' + sizes[i];
        }

    }


});


